import service from '@/utils/request'

// @Summary 用户登录
// @Produce  application/json
// @Param data body {username:"string",password:"string"}
// @Router /base/login [post]
export const getFarmList = (data) => {
  return new Promise((resolve, reject) => {
    service.post('/boss/farm/farm-list', data)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const addFarm = (data) => {
  return new Promise((resolve, reject) => {
    service.post('/boss/farm/farm-add', data)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const editFarm = (data) => {
  return new Promise((resolve, reject) => {
    service.post('/boss/farm/farm-edit', data)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const getFarmDetail = (farmId) => {
  return new Promise((resolve, reject) => {
    service.get(`/boss/farm/farm-get?farmId=${farmId}`)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const getCompanyList = (data) => {
  return new Promise((resolve, reject) => {
    service.post('/boss/tanc-company/tanc-company-list', data)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const addCompany = (data) => {
  return new Promise((resolve, reject) => {
    service.post('/boss/tanc-company/tanc-company-add', data)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const delCompany = (data) => {
  return new Promise((resolve, reject) => {
    service.post('/boss/tanc-company/tanc-company-delete', data)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const getTeamList = (data) => {
  return new Promise((resolve, reject) => {
    service.post('/boss/team/team-list', data)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const addTeam = (data) => {
  return new Promise((resolve, reject) => {
    service.post('/boss/team/add-team-member', data)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const editTeam = (data) => {
  return new Promise((resolve, reject) => {
    service.post('/boss/team/team-member-edit', data)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const getTeamDetail = (data) => {
  return new Promise((resolve, reject) => {
    service.post('/boss/team/team-member-detail', data)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const getUserList = (data) => {
  return new Promise((resolve, reject) => {
    service.post('/boss/boss-user/boss-user-list', data)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const addUser = (data) => {
  return new Promise((resolve, reject) => {
    service.post('/boss/boss-user/boss-user-add', data)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const editUser = (data) => {
  return new Promise((resolve, reject) => {
    service.post('/boss/boss-user/boss-user-edit', data)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const getRoleList = (data) => {
  return new Promise((resolve, reject) => {
    //service.post('/boss/role/role-list', data)
    service.post('/boss/role/role-company-list',data)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const addRole = (data) => {
  return new Promise((resolve, reject) => {
    service.post('/boss/role/role-add', data)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const editRole = (data) => {
  return new Promise((resolve, reject) => {
    service.post('/boss/role/role-edit', data)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const delRole = (data) => {
  return new Promise((resolve, reject) => {
    service.post('/boss/role/role-delete', data)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const getNotifyList = (data) => {
  return new Promise((resolve, reject) => {
    service.post('/boss/notify/sys-notify-list', data)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const getTeamRoleList = () => {
  return new Promise((resolve, reject) => {
    service.get('/boss/team/team-role-list')
      .then(res => {
        resolve(res.data)
      })
  })
}

export const addNotify = (data) => {
  return new Promise((resolve, reject) => {
    service.post('/boss/notify/sys-notify-add', data)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const editNotify = (data) => {
  return new Promise((resolve, reject) => {
    service.post('/boss/notify/sys-notify-edit', data)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const addNotifyDetail = (notifyId) => {
  return new Promise((resolve, reject) => {
    service.get(`/boss/notify/sys-notify-get?notifyId=${notifyId}`)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const delNotify = (data) => {
  return new Promise((resolve, reject) => {
    service.post('/boss/notify/sys-notify-delete', data)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const sendNotify = (notifyId) => {
  return new Promise((resolve, reject) => {
    service.get(`/boss/notify/farming-advice-send?notifyId=${notifyId}`)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const getFeedbacksList = (data) => {
  return new Promise((resolve, reject) => {
    service.post('/boss/user-feedbacks/user-feedbacks-list', data)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const getFeedbacksDetail = (feedbackId) => {
  return new Promise((resolve, reject) => {
    service.get(`/boss/user-feedbacks/user-feedbacks-get?feedbackId=${feedbackId}`)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const updateTeamStatus = (params) => {
  return service({
    url: `/boss/team/change-status`,
    method: 'get',
    params
  })
}

export const updateFarmStatus = (params) => {
  return service({
    url: `/boss/farm/change-farm-status`,
    method: 'get',
    params
  })
}

export const updateRoleStatus = (params) => {
  return service({
    url: `/boss/role/change-role-status`,
    method: 'get',
    params
  })
}

export const getAuthList = (data) => {
  return new Promise((resolve, reject) => {
    service.post('/boss/ResourceBossController/resources-tree', data)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const saveAuth = (data) => {
  return new Promise((resolve, reject) => {
    service.post('/boss/sys_role/updateRoleResource', data)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const getRoleAuthList = (params) => {
  return new Promise((resolve, reject) => {
    service({
      url: `/boss/role/role-resource-list`,
      method: 'get',
      params
    }).then(res => {
      resolve(res.data)
    })
  })
}

// 
export const getReportList = (data) => {
  return new Promise((resolve, reject) => {
    service.post('/boss/tanc_plantint_plan_report/list', data)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const sendSmsCode = (params) => {
  return new Promise((resolve,reject)=>{
    service.post('/anon/findpassword/send-sms-code',params)
    .then(res=>{
      resolve(res.data) 
    })
  })
}

export const verifySmsCode = (params) => {
  return new Promise((resolve,reject)=>{
    service.post('/anon/findpassword/verify-sms-code',params)
    .then(res=>{
      resolve(res.data) 
    })
  })
}

export const updatePass = (params) => {
  return new Promise((resolve,reject)=>{
    service.post('/anon/findpassword/change-password',params)
    .then(res=>{
      resolve(res.data) 
    })
  })
}

export const getReportDetail = (id) => {
  return new Promise((resolve, reject) => {
    service.get( `/boss/tanc_plantint_plan_report/get/${id}`)
      .then(res => {
        resolve(res.data)
      })
  })
}

export const deleteTeam = (data) => {
  return new Promise((resolve, reject) => {
    service.get( `/boss/team/delete-member`,{params:data})
      .then(res => {
        resolve(res.data)
      })
  })
}


export const addAddress = (params) => {
  return new Promise((resolve,reject)=>{
    service.post('/boss/exp-user-address/exp-user-address-add',params)
    .then(res=>{
      resolve(res.data) 
    })
  })
}

export const eidtAddress = (params) => {
  return new Promise((resolve,reject)=>{
    service.post('/boss/exp-user-address/exp-user-address-edit',params)
    .then(res=>{
      resolve(res.data) 
    })
  })
}

export const defaultAddress = (params) => {
  return new Promise((resolve,reject)=>{
    service.post('/boss/exp-user-address/exp-user-address-default',params)
    .then(res=>{
      resolve(res.data) 
    })
  })
}

export const deleteAddress = (params) => {
  return new Promise((resolve,reject)=>{
    service.post('/boss/exp-user-address/exp-user-address-delete',params)
    .then(res=>{
      resolve(res.data) 
    })
  })
}




